


$(function(){
    
	var jsonParam={};
	
	loadingNewData();
	//jsonParam.agentId=4677;
	sum();
	//承保前查询
	
	if($("#biaoshi").val()=="1"){
		loadingNewData('Y');
		
		//承保前汇总
		/*padMarketing.ajaxNormal(
			    '/pad_marketing/myPolicy/findUnderwriteNums.action',
			    {},
			    function(data){
			    	$(".cbq").append('<label class="tag tag_1">'+data.underwriteNum+'</label>');	//承保前
			    },
			    function(){
			    	
			    }
		)*/
		
		//policy("policyRef");
		
		/*$(".datefrom").val(newdate.Format("yyyy-MM-dd"));
		$(".dateto").val(today.Format("yyyy-MM-dd"));*/
		
	//保单状态
	padMarketing.ajaxNormal(
			'/pad_marketing/myPolicy/getPolicyStatus.action',
			{},
			function(data){
				var option="";
				//console.log(data);
				for(var i=0;i<data.length;i++){
					if(data[i].CODE < 39){
						option+="<option value="+data[i].CODE+">"+data[i].DESCRIPTION_C+"</option>";
					}
				}
				$("#understate").append(option);
				
				$("#understate option[value='30']").remove();
				$("#understate option[value='31']").remove();
				$("#understate option[value='32']").remove();
				$("#understate option[value='33']").remove();
				$("#understate option[value='34']").remove();
			},
			function(data){
				
			}
		)		
				
		padMarketing.ajaxNormal(
				'/pad_marketing/beforeUnderwriting/checkUnderwrite.action',
				{},
				function(data){
					//console.log(data);
					var datas=data;
					var cnt=[];
					var status=[];
					var sname=[];
					for(i=0;i<data.length;i++){
						if(data[i].CNT!=""||data[i].CNT!="0"){
							cnt.push(data[i].CNT);
							status.push(data[i].POLICY_STATUS);
							sname.push(data[i].POLICY_STATUS_NAME);
						}	
					}
					
					var myChart = echarts.init(document.getElementById('chars'));
					option = {
						  //tooltip: {trigger: 'axis'},
						  legnd:{data:sname},
						  xAxis: {type: 'category',axisLine:{show:false},axisTick:{show:false},data:sname},
						  grid: {left: '3%',right: '10%',bottom: '0%',top:'10%',containLabel: true},
						  yAxis: {type:"value",axisLine:{show:false},axisLabel:{show:false},axisTick:{show:false},splitLine:{show:false}},
						  series: [
						           {name: sname,type: 'bar',itemStyle:{normal:{color:"#019be1"}},barWidth:50,data:cnt,label:{normal:{show:true,position:"top",textStyle:{color:"#000"}}}},
						  ],		    		    
					};
					myChart.on('click', href);
					for(var i=0;i<option.series[0].data.length;i++){
						if(option.series[0].data[i] < 10){
							option.yAxis.max=10;
						}
						if(option.series[0].data[i] > 10){
							option.yAxis.max=option.series[0].data[i];
							break;
						}
					}
					myChart.setOption(option,true);
					
					function href(param) {    
			    		if (typeof param.seriesIndex == 'undefined') {    
					        return;    
					    }    
					    if (param.type == 'click') {    
					        //console.log(param.name);
					        //console.log(data);
					        for(n=0;n<data.length;n++){
					        	if(param.name==data[n].POLICY_STATUS_NAME){
						        	//console.log(data[n].POLICY_STATUS);
						        	jsonParam={"phName":"","policyRef":'',"style":'',"entryFrom":'',"entryTo":'',"policyStatus":data[n].POLICY_STATUS}
									//padMarketing.ajaxNormal(
										//'/pad_marketing/beforeUnderwriting/getAcceptInsurance.action',
										//jsonParam,
										//function(data){
											//console.log(data);
											window.location="/pad_marketing/MyPolicy/underlist.action?phName=&style=&entryFrom=&entryTo=&policyStatus="+data[n].POLICY_STATUS;
										//},
										//function(data){
											
										//}
									//)	
						        }
					        }
					    }    
					}
				},
				function(data){
					
				},
				true,
				true,
				'呦!你的保单很多哦!'
		)	
		
		//点击查询
		$("#select").click(function(){
			var phName=$("#underphName").val();
			var style=$("#understyle").val();
			var datestart=$(".datefrom").val();
			var dateend=$(".dateto").val();
			var statu=$("#understate").val();
			var policyRef=policyRefTo12($("#policyRef").val());
			$("#policyRef").val(policyRef);
			if(policyRef==""&&phName==""){
				if(style!=""||statu!=""){
					if(datestart=="" && dateend==""){
						alertMsg("请填写受理日期");
						return;
					}
					if(datestart!="" && dateend==""||datestart==""&&dateend!=""){
						alertMsg("受理日期输入不完整");
						return;
					}
					else{
						var dates = new Date(dateend).getTime()-new Date(datestart).getTime();
						var days = Math.floor(dates/(24*3600*1000));
						if(days>90){
							alertMsg("时间差不能超过90天")
								return;
							}
						}
					}
					else{
						if(datestart==""||dateend==""){
							alertMsg("请输入查询条件");
							return;
						}
						if(datestart!=""&&dateend==""||datestart==""&&dateend!=""){
							alertMsg("受理日期输入不完整");
							return;
						}
						else{
							var dates = new Date(dateend).getTime()-new Date(datestart).getTime();
							var days = Math.floor(dates/(24*3600*1000));
							if(days>90){
								alertMsg("时间差不能超过90天")
								return;
							}
						}
					}
				}
				style = '';
				jsonParam={"phName":phName,"policyRef":policyRef,"style":style,"entryFrom":datestart,"entryTo":dateend,"policyStatus":statu}
						//padMarketing.ajaxNormal(
							//'/pad_marketing/beforeUnderwriting/getAcceptInsurance.action',
							//jsonParam,
							//function(data){
								//console.log(data);
								window.location="/pad_marketing/MyPolicy/underlist.action?phName="+phName+"&style="+style+"&entryFrom="+datestart+"&entryTo="+dateend+"&policyStatus="+statu+"&policyRef="+policyRef;
							//},
							//function(data){
								
							//}
						//)
		})
	}
	//承保前列表   '/pad_marketing/beforeUnderwriting/getUnderwrite.action',
	if($("#biaoshi").val()=="2"){
		
		//承保前汇总
		/*padMarketing.ajaxNormal(
			    '/pad_marketing/myPolicy/findUnderwriteNums.action',
			    {},
			    function(data){
			    	$(".cbq").append('<label class="tag tag_1">'+data.underwriteNum+'</label>');	//承保前
			    },
			    function(){
			    	
			    }
		)*/
		
		var jsonParam=parseQueryString(decodeURI(window.location.href));
		var paramObj = {phName:'',style:'',entryFrom:'',entryTo:'',policyStatus:'',policyRef:''};
		$.extend(paramObj,jsonParam);
		/*if(!paramObj.url){
			$(".backspace a").attr("src","/pad_marketing/MyPolicy/underwriting.action")
		}
		else{
			
		}*/
		//jsonParam={"phName":winhref.phName,"policyRef":winhref.policyRef,"style":winhref.understyle,"entryFrom":winhref.datestart,"entryTo":winhref.dateend,"policyStatus":winhref.statu}
		padMarketing.ajaxNormal(
			'/pad_marketing/beforeUnderwriting/getAcceptInsurance.action',
			paramObj,
			function(data){
				//console.log(data);
				var contractIdList = [];
				for(var c=0;c<data.length;c++){
					contractIdList.push(data[c].CONTRACT_ID);
				}
				
				var html='';
				if(data== "" || data == undefined){
					html+="<tr><td colspan='7'>暂无记录</td></tr>";
					$("#length").text("0");
					$(".undertable tbody").append(html);
				}
				else{
					padMarketing.ajaxNormal("/pad_marketing/note/checkContractId.action",
							{"contractIdList":contractIdList},
							function(result){
								/*function compare(property){
								    return function(a,b){
								        var value1 = a[property];
								        var value2 = b[property];
								        return value1 - value2;
								    }
								}
								//console.log(result.contractId.sort(compare('contractId')));*/
								
								for(var i=0;i<data.length;i++){
									var date=new Date(data[i].PRE_ISSUE_DATE).Format("yyyy-MM-dd");
									html+='<tr data=\''+JSON.stringify(data[i])+'\'>';
									html+='<td width="160">'+data[i].POLICY_REF+'</td>';//保单号
									html+='<td width="170">'+data[i].POLICY_STATUS_NAME+'</td>';//保单状态
									html+='<td width="120">'+data[i].PH_NAME+'</td>';//投保人
									html+='<td width="130">'+data[i].PRODUCT_ID+'</td>';//主险代码
									html+='<td width="130">'+parseFloat(data[i].NB_PREMIUM)+'</td>';//总保费
									html+='<td>'+(data[i].PRE_ISSUE_DATE?date:"暂无")+'</td>';//核保通过日期
									html+='<td width="120">';
									//是否有照会要处理   页面上不显示   针对操作作处理
									if(data[i].HAS_NOTICE=="Y"){
									  	/*for(var j=0;j<result.contractId.leght;j++){
									  		if(result.contractId[j]){
										  		if(data[i].CONTRACT_ID==result.contractId[j].contractId){
										  			if(result.contractId[j].allOk=="Y"){
														html+='';
													}
													else{
														html+='<span class="icon icon-circle-xin xin"></span>';
													}
										  		}
											}
									  	}*/
										html+='<span class="icon icon-circle-xin xin"></span>';
									}
									html+='<span class="icon icon-circle-xiang check"></span></td>';
									html+='</tr>';
								}
								$("#length").text(data.length);
								un();
								$(".undertable tbody").append(html);
								$(".undertable .check").click(function(){
									$(".open-body div div p").text("");
									var undermesg=JSON.parse($(this).closest('tr').attr("data"));
									var sscdate=new Date(undermesg.SSC_KEYIN_DATE).Format("yyyy-MM-dd");
									var issuedate=new Date(undermesg.PRE_ISSUE_DATE).Format("yyyy-MM-dd");
									var lastdate=new Date(undermesg.LAST_DDA_DATE).Format("yyyy-MM-dd");
									$("#policyRef").text(undermesg.POLICY_REF);//保单号
									$("#statu").text(undermesg.POLICY_STATUS_NAME);//投保状态
									$("#phname").text(undermesg.PH_NAME);//投保人
									$("#insname").text(undermesg.INS_NAMES);//被保险人  Format
									$("#sourcedata").text(undermesg.SSC_KEYIN_DATE?sscdate:'');//受理日期
									//$("#sourcedata").text(sscdate.getFullYear()+"-"+parseInt(sscdate.getMonth()+1)+"-"+sscdate.getDate());//受理日期
									$("#sourcename").text(undermesg.SOURCE_NAME);//出单方式
									$("#proid").text(undermesg.PRODUCT_ID);//主险代码
									$("#proname").text(undermesg.PRODUCT_NAME);//主险名称
									$("#premium").text(undermesg.NB_PREMIUM);//总保费
									$("#adoptdate").text(undermesg.PRE_ISSUE_DATE?issuedate:"");//核保通过日期
									$("#pay").text(undermesg.NB_PAYMENT_METHOD_NAME);//支付方式
									$("#back").text(undermesg.DDA_BANK_NAME);//转账银行
									$("#backlast").text(undermesg.DDA_BANK_ACCOUNT_NO?undermesg.DDA_BANK_ACCOUNT_NO.substr(undermesg.DDA_BANK_ACCOUNT_NO.length-4):'');//账号末四位
									$("#perdata").text(undermesg.LAST_DDA_DATE?lastdate:"");//上次扣款日期
									$("#reason").text(undermesg.LAST_DDA_FAIL_REASON);//扣款失败原因
									showDiv("open1");
								})
								
								//新业务照会
								$(".undertable .xin").click(function(){
									var undermesg=JSON.parse($(this).closest('tr').attr("data"));
									sessionStorage.contractId=undermesg.CONTRACT_ID;
									sessionStorage.policyRef=undermesg.POLICY_REF;
									//console.log(undermesg);
									var value="&contractId="+undermesg.CONTRACT_ID+"&policyRef="+undermesg.POLICY_REF+"&productname="+undermesg.PRODUCT_NAME;
									var href=window.location.href;
									//window.location="/pad_marketing/note/noteContent.action?url="+href+value;
									window.location="/pad_marketing/note/noteContent.action.action?"+value+"&url="+encodeURIComponent(href);
								})
								//table();
							},
							function(result){
								
							}
					)
				}
			},
			function(data){
					
			},
			true,
			true,
			'呦!你的保单很多哦!'
		);
	}
	
	//新单追踪查询    
	if($("#biaoshi").val()=="3"){
		
		//新单追踪汇总
		/*padMarketing.ajaxNormal(
			    '/pad_marketing/myPolicy/findNewOrdersNum.action',
			    {},
			    function(data){
			    	$(".xdzz").append('<label class="tag tag_1">'+data.newOrdersNum+'</label>');	//承保前
			     	
			    },
			    function(){
			    	
			    }
		)*/
		
		//policy("polno");
		/*$(".datefrom").val(newdate.Format("yyyy-MM-dd"));
		$(".dateto").val(today.Format("yyyy-MM-dd"));*/
		
		//柱状图
		padMarketing.ajaxNormal(
				'/pad_marketing/myPolicy/getNewOrdersChart.action',
				{},
				function(data){
					//console.log(data)
					var cnt1=[];
					var cnt2=[];
					var cnt3=[];
					var tas=[];
					var rstatu=[];
					var rstan=[];
					var statu=[];
					var stan=[];
					
					for(i=0;i<data.length;i++){
						if(data[i].CNT!=""||data[i].CNT!="0"){
							//cnt.push("{value:"+data[i].CNT+",itemStyle:{normal:{color:'#019be1'}}}}");
							if(data[i].TASKSTATUS){
								if(data[i].TASKSTATUS=="New"){
//									tas.push("投保资料未上传");
//									data[i].TASKSTATUSNAME="投保资料未上传";
									tas.push("资料未上传");
									data[i].TASKSTATUSNAME="资料未上传";
								}
								if(data[i].TASKSTATUS=="Scanned"){
//									tas.push("投保资料或照会回复已上传");
//									data[i].TASKSTATUSNAME="投保资料或照会回复已上传";
									tas.push("待质检");
									data[i].TASKSTATUSNAME="待质检";
								}
								if(data[i].TASKSTATUS=="Pending"){
									tas.push("质检进行中");
									data[i].TASKSTATUSNAME="质检进行中";
								}
								if(data[i].TASKSTATUS=="Back to Scan"){
//									tas.push("需要重新上传投保资料");
//									data[i].TASKSTATUSNAME="需要重新上传投保资料";
									tas.push("待重新上传");
									data[i].TASKSTATUSNAME="待重新上传";
								}
								if(data[i].TASKSTATUS=="Follow-up"){
//									tas.push("质检照会未回复");
//									data[i].TASKSTATUSNAME="质检照会未回复";
									tas.push("照会未回复");
									data[i].TASKSTATUSNAME="照会未回复";
								}
								if(data[i].TASKSTATUS=="Confirm"){
									tas.push("质检通过");
									data[i].TASKSTATUSNAME="质检通过";
								}
								cnt1.push(data[i].CNT);
								//tas.push(data[i].TASKSTATUS);
								//$("#qcstatus").append("<option value="+data[i].TASKSTATUS+">"+data[i].TASKSTATUS+"</option>");								
								//input1 = input1+'{value:'+data[i].CNT+',itemStyle:{normal:{color:"#019be1"}}},';								
							}else{
								//cnt1.push("");
							}						
							if(data[i].RCPT_STATUS_NAME){				
								cnt2.push(data[i].CNT);
								rstan.push(data[i].RCPT_STATUS_NAME);
								//$("#rcptstatus").append("<option value="+data[i].RCPT_STATUS+">"+data[i].RCPT_STATUS_NAME+"</option>")
								//input2 = input2+'{value:'+data[i].CNT+',itemStyle:{normal:{color:"#019be1"}}},';								
								
							}else{
								//cnt2.push("");
							}						
							if(data[i].RCPT_STATUS){
								rstatu.push(data[i].RCPT_STATUS);
							}
							if(data[i].STATUS){								
								statu.push(data[i].STATUS);							
							}
							if(data[i].STATUS_NAME){
								cnt3.push(data[i].CNT);
								stan.push(data[i].STATUS_NAME);
								//$("#rcstatus").append("<option value="+data[i].STATUS+">"+data[i].STATUS_NAME+"</option>");
								//input3 = input3+'{value:'+data[i].CNT+',itemStyle:{normal:{color:"#019be1"}}},';								
							}else{
								//cnt3.push("");
							}
						}
					}
					var name=[];
					var zcnt=[];					
					zcnt=zcnt.concat(cnt2.concat(cnt3.concat(cnt1)));
					name=name.concat(rstan.concat(stan.concat(tas)));
					
					//#019be1    #ff5400    #66be1e
					var myChart = echarts.init(document.getElementById('chars'));
					option = {
						  //tooltip: {trigger: 'axis'},
						  legnd:{data:name},
						  grid: {left: '3%',right: '10%',bottom: '5%',top:'5%',containLabel: true},
						  yAxis: {type:"value",axisLine:{show:false},axisLabel:{show:false},axisTick:{show:false},splitLine:{show:false}},
						  xAxis: {type: 'category',axisLine:{show:false},axisTick:{show:false},data:name},
						  series: [
						      {name: "CNT",type: 'bar',itemStyle:{normal:{color:function(params){
						    	// build a color map as your need.
			                        var colorList = ['#019be1','#ff5400','#66be1e'];
			                   
			                        if(params.dataIndex <= cnt2.length-1){
			                        	return colorList[0];
			                        }
			                        if(params.dataIndex <= cnt2.length+cnt3.length-1 && params.dataIndex >= cnt2.length-1){
			                        	return colorList[1]
			                        }
			                        if(params.dataIndex > cnt2.length+cnt3.length-1 ){
			                        	return colorList[2]
			                        }
						    	  
						      }}},barWidth:50,data:zcnt,label:{normal:{show:true,position:"top",textStyle:{color:"#000"}}}},
						      /* {name: "CNT",type: 'bar',itemStyle:{normal:{color:"#019be1"}},barWidth:30,data:cnt1,label:{normal:{show:true,position:"top",textStyle:{color:"#000"}}}},
						      {name: "CNT2",type: 'bar',itemStyle:{normal:{color:"#ff5400"}},barWidth:30,data:cnt2,label:{normal:{show:true,position:"top",textStyle:{color:"#000"}}}},
						      {name: "CNT3",type: 'bar',itemStyle:{normal:{color:"#66be1e"}},barWidth:30,data:cnt3,label:{normal:{show:true,position:"top",textStyle:{color:"#000"}}}},
							  */
						  ],
					};
					myChart.on('click', href);
					for(var i=0;i<option.series[0].data.length;i++){
						//console.log(option.series[0].data[i]);
						if(option.series[0].data[i] < 10){
							option.yAxis.max=10;
						}
						if(option.series[0].data[i] > 10){
							option.yAxis.max=option.series[0].data[i];
							break;
						}
					}
					
					myChart.setOption(option,true);
					
					var tl='';
					tl+="<div class='tl' style='width:100%;height:25px;text-align:center;position:relative'>";
					tl+="<li style='margin-right:20px;display:inline-block;list-style:none;top:15%;font-size:12px'><span style='width:3px;height:1px;background-color:#019be1;padding: 0.5px 15px;margin-right:5px'></span>回执</li>";
					tl+="<li style='margin-right:20px;display:inline-block;list-style:none;top:15%;font-size:12px'><span style='width:3px;height:1px;background-color:#ff5400;padding: 0.5px 15px;margin-right:5px'></span>回访</li>";
					tl+="<li style='margin-right:20px;display:inline-block;list-style:none;top:15%;font-size:12px'><span style='width:3px;height:1px;background-color:#66be1e;padding: 0.5px 15px;margin-right:5px'></span>质检</li>";
					tl+="</div>";					
					$("#chars").after(tl);
					
					function href(param) {    
			    		if (typeof param.seriesIndex == 'undefined') {    
					        return;    
					    }    
					    if (param.type == 'click') {
					        //console.log(param.dataIndex)
					        for(n=0;n<data.length;n++){
				        		
				        		//console.log(data);
					        	if(param.name == data[n].TASKSTATUSNAME){
						        	//console.log(data[n].TASKSTATUS);
						        	var task=data[n].TASKSTATUS;
						        	jsonParam={"phName":'',"policyRef":'',"rcptStatus":'',"rcStatus":'',"qcStatus":task,"issueDateFrom":'',"issueDateTo":''};
									//padMarketing.ajaxNormal(
										//'/pad_marketing/myPolicy/getAllTrace.action',
										//jsonParam,
										//function(data){
											//console.log(data);
											window.location="/pad_marketing/MyPolicy/tracklist.action?phName=&policyRef=&rcptStatus=&rcStatus=&qcStatus="+task+"&issueDateFrom=&issueDateTo=";
										//},
										//function(data){
											
										//}
									//)	
						        }
					        	
					        	if(param.name == data[n].RCPT_STATUS_NAME){
						        	//console.log(data[n].RCPT_STATUS);
						        	var rcpt=data[n].RCPT_STATUS;
						        	jsonParam={"phName":'',"policyRef":'',"rcptStatus":data[n].RCPT_STATUS,"rcStatus":'',"qcStatus":'',"issueDateFrom":'',"issueDateTo":''};
									//padMarketing.ajaxNormal(
										//'/pad_marketing/myPolicy/getAllTrace.action',
										//jsonParam,
										//function(data){
											//console.log(data);
											window.location="/pad_marketing/MyPolicy/tracklist.action?phName=&policyRef=&rcptStatus="+rcpt+"&rcStatus=&qcStatus=&issueDateFrom=&issueDateTo=";
										//},
										//function(data){
											
										//}
									//)	
									return
						        }
					        						        	
					        	if(param.name == data[n].STATUS_NAME){
						        	//console.log(data[n].STATUS);
						        	var rcsta=data[n].STATUS;
						        	jsonParam={"phName":'',"policyRef":'',"rcptStatus":'',"rcStatus":data[n].STATUS,"qcStatus":'',"issueDateFrom":'',"issueDateTo":''};
									//padMarketing.ajaxNormal(
										//'/pad_marketing/myPolicy/getAllTrace.action',
										//jsonParam,
										//function(data){
											//console.log(data);
											window.location="/pad_marketing/MyPolicy/tracklist.action?phName=&policyRef=&rcptStatus=&rcStatus="+rcsta+"&qcStatus=&issueDateFrom=&issueDateTo=";
										//},
										//function(data){
											
										//}
									//)
									return
						        }
					        }
					    }    
					}
				},
				function(data){
					
				},
				true,
				true,
				'呦!你的保单很多哦!'
		)
		$("#select").click(function(){
			var phName=$("#phName").val();
			//var policyRef=$("#polno").val();
			var rcptStatus=$("#rcptstatus").val();
			var rcStatus=$("#rcstatus").val();
			var qcStatus=$("#qcstatus").val();						
			var issueDateFrom=$(".datefrom").val();
			var issueDateTo=$(".dateto").val();
			var policyRef=policyRefTo12($("#polno").val());
			$("#polno").val(policyRef);
						
			if(policyRef=="" && phName==""){
				if(rcptStatus!=""||rcStatus!=""||qcStatus!=""){
					if(issueDateFrom==""&&issueDateTo==""){
						alertMsg("请选择日期");
						return;
					}
					if(issueDateFrom!=""&&issueDateTo==""||issueDateFrom==""&&issueDateTo!=""){
						alertMsg("承保日期输入不完整");
						return;
					}
					else{
						var dates = new Date(issueDateFrom).getTime()-new Date(issueDateTo).getTime();
						var days = Math.floor(dates/(24*3600*1000));
						if(days>90){
							alertMsg("时间差不能超过90天")
							return;
						}
					}
				}
				else{
					if(issueDateFrom==""&&issueDateTo==""){
						alertMsg("请选择日期");
						return;
					}
					if(issueDateFrom!=""&&issueDateTo==""||issueDateFrom==""&&issueDateTo!=""){
						alertMsg("承保日期输入不完整");
						return;
					}
					else{
						var dates = new Date(issueDateFrom).getTime()-new Date(issueDateTo).getTime();
						var days = Math.floor(dates/(24*3600*1000));
						if(days>90){
							alertMsg("时间差不能超过90天")
							return;
						}
					}
				}
			}
						
			jsonParam={"phName":phName,"policyRef":policyRef,"rcptStatus":rcptStatus,"rcStatus":rcStatus,"qcStatus":Number(qcStatus),"issueDateFrom":issueDateFrom,"issueDateTo":issueDateTo};
						//console.log(jsonParam)
						//padMarketing.ajaxNormal(
								//'/pad_marketing/myPolicy/getAllTrace.action',
								//jsonParam,
								//function(data){
									//console.log(data);
						window.location="/pad_marketing/MyPolicy/tracklist.action?phName="+phName+"&policyRef="+policyRef+"&rcptStatus="+rcptStatus+"&rcStatus="+rcStatus+"&qcStatus="+qcStatus+"&issueDateFrom="+issueDateFrom+"&issueDateTo="+issueDateTo;
								//},
								//function(data){
									
								//}
						//)
		})
	}
	//新单追踪列表
	if($("#biaoshi").val()=="4"){
		//新单追踪汇总
		/*padMarketing.ajaxNormal(
			    '/pad_marketing/myPolicy/findNewOrdersNum.action',
			    {},
			    function(data){
			    	$(".xdzz").append('<label class="tag tag_1">'+data.newOrdersNum+'</label>');	//承保前
			   },
			    function(){
			    	
			    }
		)*/
		
		///pad_marketing/myPolicy/getNewOrders.action
		var jsonParam=parseQueryString(decodeURI(window.location.href));
		var paramObj = {phName:'',policyRef:'',rcptStatus:'',rcStatus:'',qcStatus:'',issueDateFrom:'',issueDateTo:''};
		$.extend(paramObj,jsonParam);
		padMarketing.ajaxNormal(
				'/pad_marketing/myPolicy/getAllTrace.action',
				paramObj,
				function(data){
					//console.log(data);
					var html='';
					var contractIdList=[];
					for(var c=0;c<data.length;c++){
						contractIdList.push(data[c].CONTRACT_ID);
					}
					
					if(data== "" || data == undefined){
						html+="<tr><td colspan='7'>暂无记录</td></tr>";
						$("#length").text("0");
						$(".tracktable tbody").append(html);
					}
					else{
						
						padMarketing.ajaxNormal(
								"/pad_marketing/qualityCheck/checkContractId.action",
								{"contractIdList":contractIdList},
								function(result){
									//console.log(result);
									/*function compare(property){
									    return function(a,b){
									        var value1 = a[property];
									        var value2 = b[property];
									        return value1 - value2;
									    }
									}
									//console.log(result.contractId.sort(compare('contractId')));*/
									
									for(var i=0;i<data.length;i++){
										var date=new Date(data[i].ISSUE_DATE).Format("yyyy-MM-dd");
										html+='<tr data=\''+JSON.stringify(data[i])+'\'>';
										html+='<td width="160">'+data[i].POLICY_REF+'</td>';//保单号
										html+='<td width="130">'+data[i].PH_NAME+'</td>';//投保人
										html+='<td>'+(data[i].ISSUE_DATE?date:"暂无日期")+'</td>';//承保日期
										html+='<td width="120">'+data[i].RCPT_STATUS_NAME+'</td>';//回执状态
										html+='<td width="120">'+data[i].RC_STATUS_NAME+'</td>';//回访状态
										html+='<td width="120">'+data[i].QC_STATUS_NAME+'</td>';//质检状态
										html+='<td width="200">';
										if(data[i].RC_NOTICE_TYPE=="3"){
											html+='<span class="icon icon-circle-fang fang"></span>';
										}
										if(data[i].HAS_QC_NOTICE=="Y"){
											for(var j=0;j<result.contractId.length;j++){
												if(result.contractId[j]){
													if(data[i].CONTRACT_ID==result.contractId[j].contractId){
														if(result.contractId[j].allOk=="Y"){
															html+='';
														}
														else{
															html+='<span class="icon icon-circle-zhi zhi"></span>';
														}
													}
												}
												else{
													html+='<span class="icon icon-circle-zhi zhi"></span>';
												}
											}
											if(result.contractId.length==0){
												html+='<span class="icon icon-circle-zhi zhi"></span>';
											}
										}
										if(data[i].RCPT_STATUS=="01"){
											html+='<span class="icon icon-circle-qian qian"></span>';
										}
										html+='<span class="icon icon-circle-xiang check"></span></td>';
										//html+='<td><span class="icon icon-circle-fang"></span><span class="icon icon-circle-zhi"></span><span class="icon icon-circle-qian"></span><span class="icon icon-circle-xiang check"></span></td>';
										html+='</tr>';
										
									}
									$("#length").text(data.length);
									$(".tracktable tbody").append(html);
									un();
									//回访
									
									$(".tracktable .fang").click(function(){
										var undermesg=JSON.parse($(this).closest('tr').attr("data"));
										//var jsonParam={};
										//jsonParam.contractId = undermesg.CONTRACT_ID;
										jsonParam.policyRef=undermesg.POLICY_REF
										padMarketing.ajaxNormal(
											'/pad_marketing/notes/getPDFUrl.action',jsonParam,
											function(data) {
												//console.log(data);
												//goPdfShow(data[0].LETTER_PARAMS);
												gotoPDF('pdfRefresh',data[0].LETTER_PARAMS,undefined,undefined);
											},
											function(data){
												
											}
										)//调用失败结果
									})
									
									//质检照会
									$(".tracktable .zhi").click(function(){
										var undermesg=JSON.parse($(this).closest('tr').attr("data"));
										sessionStorage.contractId=undermesg.CONTRACT_ID; //保单内部IT
										sessionStorage.policyRef=undermesg.POLICY_REF;	//保单号
										//sessionStorage.abbr_name=undermesg.ABBR_NAME; //主险名称	
										/*var value="&contractId="+undermesg.CONTRACT_ID+"&policyRef="+undermesg.POLICY_REF;
										var href=window.location.pathname+value;//当前url
										window.location = "/pad_marketing/qualityCheck/noteDetailQC.action?Url="+href+value;*/
										var value="policyref="+undermesg.POLICY_REF+"&contractid="+undermesg.CONTRACT_ID;
										var href=window.location.href;//当前url
										window.location="/pad_marketing/qualityCheck/noteDetailQC.action?"+value+"&url="+encodeURIComponent(href);
									})
									
									//电子回执
									$(".tracktable .qian").click(function(){
										var undermesg=JSON.parse($(this).closest('tr').attr("data"));
										var value="policyref="+undermesg.POLICY_REF+"&contractid="+undermesg.CONTRACT_ID;
										var href=window.location.href;//当前url
										window.location="/pad_marketing/note/eReceipt.action?"+value+"&url="+encodeURIComponent(href);
										//console.log("/pad_marketing/note/eReceipt.action?"+value+"&url="+encodeURIComponent(href))
									})
									
									//详情
									$(".tracktable .check").click(function(){
										$(".open-body div div p").text("");
										var undermesg=JSON.parse($(this).closest('tr').attr("data"));
										var rcptdate=new Date(undermesg.RCPT_STATUS_DATE).Format("yyyy-MM-dd");
										var qcdate=new Date(undermesg.QC_STATUS_DATE).Format("yyyy-MM-dd");
										var rcdate=new Date(undermesg.RC_STATUS_DATE).Format("yyyy-MM-dd");
										var sscdate=new Date(undermesg.ISSUE_DATE).Format("yyyy-MM-dd");
										$("#policyRef").text(undermesg.POLICY_REF);//保单号
										$("#phname").text(undermesg.PH_NAME);//投保人
										$("#rcptdate").text(undermesg.RCPT_STATUS_DATE?rcptdate:"");//回执更新受理日期
										$("#rcptname").text(undermesg.RCPT_STATUS_NAME);//回执状态						
										$("#qcdate").text(undermesg.RC_STATUS_DATE?rcdate:"");//回访更新受理日期
										$("#qcname").text(undermesg.RC_STATUS_NAME);//回访状态				
										$("#rcdate").text(undermesg.QC_STATUS_DATE?qcdate:"");//质检更新受理日期
										$("#rcname").text(undermesg.QC_STATUS_NAME);//质检状态
										$("#issdate").text(undermesg.ISSUE_DATE?sscdate:"");//承保日期	
										showDiv("open1");
									})
									
								},
								function(result){
									
								}
						)
					}
					
					
					
				},
				function(data){
					
				},
				true,
				true,
				'呦!你的保单很多哦!'
		)
	}
	
	//保全查询
	if($("#biaoshi").val()=="5"){
		//保全汇总
		/*padMarketing.ajaxNormal(
			    '/pad_marketing/myPolicy/findAcceptNums.action',
			    {},
			    function(data){
			    	$(".bq").append('<label class="tag tag_1">'+data.acceptNum+'</label>');	//承保前
			     	
			    },
			    function(){
			    	
			    }
		)*/
		
		//policy("polid");
		/*$(".datefrom").val(newdate.Format("yyyy-MM-dd"));
		$(".dateto").val(today.Format("yyyy-MM-dd"));*/
		
		//保全项目下拉框
		padMarketing.ajaxNormal(
				'/pad_marketing/Pstate/getPitem.action',
				{},
				function(data){
					//console.log(data);
					var html="";
					for(var j=0;j<data.length;j++){
						html+="<option value="+data[j].MOVEMENT_CODE+">"+data[j].CHINESE_DESC+"</option>";			
					}
					$("#pitem").append(html);
				},
				function(data){
					
				}
		)
		
		//保全状态下拉框
		/*padMarketing.ajaxNormal(
				'/pad_marketing/Pstate/getPtate.action',
				{},
				function(data){
					//console.log(data);
					var html="";
					for(var j=0;j<data.length;j++){
						html+="<option>"+data[j].WEB_DISPLAY_NAME+"</option>";
					}
					$("#ptate").append(html);
				},
				function(data){
					
				}
		)*/
		
		//柱状图
		
		padMarketing.ajaxNormal(
				'/pad_marketing/accept/allAccept.action',
				{},
				function(data){
					//console.log(data);
					//var zdata=[];
					var name=[];
					var num=[];
					//acceptRefuse         拒绝
					//charge               收费中
					//closed               结案
					//histogramChange      变更处理中
					//price                计价中
					//withdraw             撤销
					//变更处理中    收费中    计价中    撤销    拒绝    结案
					
					var zdata=[
					           {"status":"变更处理中","num":data.histogramChange[0].CT},
					           {"status":"收费中","num":data.charge[0].CT},
					           {"status":"记价中","num":data.price[0].CT},
					           {"status":"撤销","num":data.withdraw[0].CT},
					           {"status":"拒绝","num":data.acceptRefuse[0].CT},
					           {"status":"结案","num":data.closed[0].CT}
					         ]
					//console.log(zdata);
					for(var i=0;i<zdata.length;i++){
						if(zdata[i].num!=0){
							name.push(zdata[i].status);
							num.push(zdata[i].num);
						}
					}
					
					var myChart = echarts.init(document.getElementById('chars'));
					option = {
						  //tooltip: {trigger: 'axis'},
						  legnd:{data:name},
						  xAxis: {type: 'category',axisLine:{show:false},axisTick:{show:false},data:name},
						  grid: {left: '3%',right: '10%',bottom: '0%',top:'10%',containLabel: true},
						  yAxis: {type:"value",axisLine:{show:false},axisLabel:{show:false},axisTick:{show:false},splitLine:{show:false}},
						  series: [
						           {name: "数量",type: 'bar',itemStyle:{normal:{color:"#019be1"}},barWidth:50,data:num,label:{normal:{show:true,position:"top",textStyle:{color:"#000"}}}},
						  ],		    		    
					};
					myChart.on('click', href);
					for(var i=0;i<option.series[0].data.length;i++){
						if(option.series[0].data[i] < 10){
							option.yAxis.max=10;
						}
						if(option.series[0].data[i] > 10){
							var max = Math.max.apply(null, option.series[0].data);
							option.yAxis.max=max;
							break;
						}
						if(option.series[0].data[i] > 10){
							option.yAxis.max=option.series[0].data[i];
							break;
						}
						
					}
					myChart.setOption(option,true);
					function href(param) {
			    		if (typeof param.seriesIndex == 'undefined') {    
					        return;
					    }
					    if (param.type == 'click') {    
					        
					        for(n=0;n<zdata.length;n++){
					        	if(param.name==zdata[n].status){
					        		var status = zdata[n].status;
					        		
						        	jsonParam={"polCode":'',"status":status,"entryFrom":'',"entryTo":'',"policyRef":'',"phName":''}
						        	//console.log(jsonParam)
						        	//padMarketing.ajaxNormal(
										//'/pad_marketing/mainten/getMaintenList.action',
										//jsonParam,
										//function(data){
											//console.log(data);
											window.location="/pad_marketing/MyPolicy/claimslist.action?policyRef=&phName=&status="+status+"&entryFrom=&entryTo=&polCode=";
										//},
										//function(data){
											
										//}
									//)	
						        }
					        }
					    }    
					}
				},
				function(data){
					
				},
				true,
				true,
				'呦!你的保单很多哦!'
			);
		
		$("#select").click(function(){
			var phname=$("#polname").val();
			//var polid=$("#polid").val();
			//var pitem=$("#pitem :selected").text();
			var pitem=$("#pitem").val();
			var ptate=$("#ptate").val();
			var datastart=$(".datefrom").val();
			var dataend=$(".dateto").val();
			
			var polid=policyRefTo12($("#polid").val());
			$("#polid").val(polid);
			
			/*if(phname=="" && polid==""){
				if(ptate=="" && pitem=="" ){
					if(datastart==""&&dataend==""){
						alertMsg("请输入查询条件");
						return;
					}
					if(datastart!=""&&dataend==""||datastart==""&&dataend!=""){
						alertMsg("受理日期输入不完整");
						return;
					}
					else{
						alertMsg("请输入保单状态");
						return;
					}
				}
				
				else{
					if(datastart==""&&dataend==""){
						alertMsg("请输入受理日期");
						return;
					}*/
					if(datastart!=""&&dataend==""||datastart==""&&dataend!=""){
						alertMsg("受理日期输入不完整");
						return;
					}
					if(datastart!=""||dataend!=""){
						var dates = new Date(datastart).getTime()-new Date(dataend).getTime();
						var days = Math.floor(dates/(24*3600*1000));
						if(days>90){
							alertMsg("时间差不能超过90天")
							return;
						}
					}
				//}
			//}
			//jsonParam={"polCode":pitem,"status":ptate,"entryFrom":datastart,"entryTo":dataend,"policyRef":polid,"phName":phname}
			window.location="/pad_marketing/MyPolicy/claimslist.action?policyRef="+polid+"&polCode="+pitem+"&phName="+phname+"&status="+ptate+"&entryFrom="+datastart+"&entryTo="+dataend;
					
		})
		
	}
	
	//保全列表
	if($("#biaoshi").val()=="6"){
		//保全汇总
		/*padMarketing.ajaxNormal(
			    '/pad_marketing/myPolicy/findAcceptNums.action',
			    {},
			    function(data){
			    	 $(".bq").append('<label class="tag tag_1">'+data.acceptNum+'</label>');	//承保前
			     	 
			    },
			    function(){
			    	
			    }
		)*/
		
		var jsonParam=parseQueryString(decodeURI(window.location.href));
		var paramObj = {policyRef:'',polCode:'',phName:'',status:'',entryFrom:'',entryTo:''};
		$.extend(paramObj,jsonParam);
		padMarketing.ajaxNormal(
				'/pad_marketing/mainten/getMaintenList.action',
				paramObj,
				function(data){
					//console.log(data);
					var html='';
					if(data == '' || data == "undefined"){
						html='<tr><td colspan="7">暂无符合数据</td></tr>';
						$("#length").text("0");
						$(".claimstable tbody").append(html);
					}
					else{
						for(var i=0;i<data.length;i++){
							var date=new Date(data[i].APPLY_DATE).Format("yyyy-MM-dd");;
							html+='<tr data=\''+JSON.stringify(data[i])+'\'>';
							html+='<td width="160">'+data[i].POLICYREF+'</td>';//保单号
							html+='<td width="120">'+data[i].PH_NAME+'</td>';//投保人
							html+='<td width="120">'+data[i].COVER_CODE+'</td>';//主线代码
							//html+='<td>'+data[i].MOVEMENT_DESC_C+'</td>';//保全项目
							html+='<td width="200">'+data[i].CHINESE_DESC+'</td>';//保全项目
							html+='<td>'+(data[i].APPLY_DATE?date:"")+'</td>'//受理日期
							html+='<td width="120">'+data[i].WEB_DISPLAY_NAME+'</td>';//保全状态
							html+='<td width="120">'
							if(data[i].NOTICE_ID){
								html+='<span class="icon icon-circle-bian bian"></span>';
							}
							else{
								html+='';
							}
							html+='<span class="icon icon-circle-xiang check"></span></td>';
							html+='</td>';
							html+='</tr>';
						}
						$("#length").text(data.length);
						$(".claimstable tbody").append(html);
					}
					//table();
					un();
					
					$(".claimstable .bian").click(function(){						
						var undermesg=JSON.parse($(this).closest('tr').attr("data"));
						var noticeId = undermesg.NOTICE_ID;
						var contractId = undermesg.CONTRACT_ID;
						
						//sign获取
						var signKey = String(contractId)+noticeId+"NEWTOUCH";
						$.ajax({
							  url: '/pad_marketing/main/getSign.action',
							  data: {'jsonParam':JSON.stringify({signKey:signKey})},
							  success: function(data){
								  sign = data.sign;
								  address = data.address;
							  },
							  async:false
							}); 
						//thisUrl = window.document.location.pathname;//当前URL

						//保全照会URL
						var pdfUrl = address+"/POSNotice?contractId="+contractId+"&noticeId="+noticeId+"&partner=NEWTOUCH&sign="+sign;
						
						//调壳弹出新页面，参数说明：1：回调函数名称，2：要展示的地址，3：回调函数参数，4：是否需要签字
						gotoPDF('pdfRefresh',pdfUrl,0,'N');
					})
					
					$(".claimstable .check").click(function(){
						$(".open-body div div p").text("");
						var undermesg=JSON.parse($(this).closest('tr').attr("data"));
						//console.log(undermesg);
						padMarketing.ajaxNormal(
								'/pad_marketing/mainten/getMaintenDetailByContractId.action',
								{contractId:undermesg.CONTRACT_ID},
								function(result){
									//console.log(result);
									for(var i=0;i<result.length;i++){
										if(result[i].TASKIDS==undermesg.SUB_TASK_ID){
											$("#movement").text(result[i].MOVEMENT_DESC_C);//保全项目
											$("#taskstatu").text(result[i].TASK_STATUS?result[i].TASK_STATUS:undermesg.TASK_STATUS);//保全状态
											$("#noticeflag").text(result[i].NOTICE_FLAG_CN);//照会状态
											$("#regchannel").text(result[i].REG_CHANNEL_DESC);//申请方式
											$("#reject").text(result[i].REJECT_REASON);//拒绝/撤销原因
											$("#register").text(result[i].REGISTER_DATE?new Date(result[i].REGISTER_DATE).Format('yyyy-MM-dd'):'');//申请日期
											$("#submit").text(result[i].SUBMIT_DATE?new Date(result[i].SUBMIT_DATE).Format('yyyy-MM-dd'):'');//受理完成日期
											$("#pseff").text(result[i].PS_EFF_DATE?new Date(result[i].PS_EFF_DATE).Format('yyyy-MM-dd'):'');//生效日期
											$("#close").text(result[i].CLOSE_DATE?new Date(result[i].CLOSE_DATE).Format('yyyy-MM-dd'):'');//完成日期
										}
									}
									showDiv("open1");
								},
								function(){
															
								}
						)
						showDiv("open1");
						/*sessionStorage.data=JSON.stringify(undermesg);
						//window.location="/pad_marketing/MyPolicy/query.action?page=bq"+"&data="+JSON.stringify(undermesg);
						window.location="/pad_marketing/MyPolicy/query.action?page=bq";*/
					})
				},
				function(data){
					
				},
				true,
				true,
				'呦!你的保单很多哦!'
			);
	}
	
	//理赔详情
	if($("#biaoshi").val()=="7"){
		//理赔汇总
		/*padMarketing.ajaxNormal(
			    '/pad_marketing/myPolicy/findClaimNums.action',
			    {},
			    function(data){
			    	$(".lp").append('<label class="tag tag_1">'+data.claimNum+'</label>');	//承保前
			     	
			    },
			    function(){
			    	
			    }
		)*/
		
		//policy("spolicy");
		/*$(".datefrom").val(newdate.Format("yyyy-MM-dd"));
		$(".dateto").val(today.Format("yyyy-MM-dd"));*/
		//柱状图
		padMarketing.ajaxNormal(
				'/pad_marketing/myPolicy/getClaimChart.action',
				{},
				function(data){
					//console.log(data);
					var status=[];
					var num=[];
					for(i=0;i<data.length;i++){
						if(data[i]){
							if(data[i].CLAIM_STATUS=="P"){
								data[i].CLAIM_STATUS_NAME="审核中";
								status.push("审核中");
								num.push(data[i].NUM);
							}
							
							if(data[i].CLAIM_STATUS=="R"){
								data[i].CLAIM_STATUS_NAME="受理中";
								status.push("受理中");
								num.push(data[i].NUM);
							}
							if(data[i].CLAIM_STATUS=="C"){
								data[i].CLAIM_STATUS_NAME="案件撤销";
								status.push("案件撤销");
								num.push(data[i].NUM);
							}
							if(data[i].CLAIM_STATUS=="F"){
								data[i].CLAIM_STATUS_NAME="已结案";
								status.push("已结案");
								num.push(data[i].NUM);
							}
							
							//status.push(data[i].CLAIM_STATUS);
							//num.push(data[i].NUM);
						}
					}
					var myChart = echarts.init(document.getElementById('chars'));
					option = {
						  //tooltip: {trigger: 'axis'},
						  legnd:{data:status},
						  xAxis: {type: 'category',axisLine:{show:false},axisTick:{show:false},data:status},
						  grid: {left: '3%',right: '10%',bottom: '0%',top:'10%',containLabel: true},
						  yAxis: {type:"value",axisLine:{show:false},axisLabel:{show:false},axisTick:{show:false},splitLine:{show:false}},
						  series: [
						           {name: "数量",type: 'bar',itemStyle:{normal:{color:"#019be1"}},barWidth:50,data:num,label:{normal:{show:true,position:"top",textStyle:{color:"#000"}}}},
						  ],
					};
					myChart.on('click', href);	
					
					for(var i=0;i<option.series[0].data.length;i++){
						if(option.series[0].data[i] < 10){
							option.yAxis.max=10;
						}
						if(option.series[0].data[i] > 10){
							option.yAxis.max=option.series[0].data[i];
							break;
						}
					}
					myChart.setOption(option,true);	
					function href(param) {
			    		if (typeof param.seriesIndex == 'undefined') {    
					        return;
					    }
					    if (param.type == 'click'){
					    	for(var i=0;i<data.length;i++){
					        	if(param.name==data[i].CLAIM_STATUS_NAME){
					        		var status=data[i].CLAIM_STATUS;
					        		window.location="/pad_marketing/MyPolicy/preserlist.action?insuredName=&policyRef=&regDateFrom=&regDateTo=&claimStatus="+status;
					        		//jsonParam={"insuredName":'',"policyRef":'',"regDateFrom":'',"regDateTo":'',"claimStatus":status};
									//padMarketing.ajaxNormal(
										//'/pad_marketing/myPolicy/queryClaims.action',
										//jsonParam,
										//function(data){
											//console.log(data);
											//window.location="/pad_marketing/MyPolicy/preserlist.action?insuredName="+status+"&policyRef=&regDateFrom=&regDateTo=";
										//},
										//function(data){
													
										//}
									//)	
					        	}
					    	}
					    }    
					}
				},
				function(data){
					
				},
				true,
				true,
				'呦!你的保单很多哦!'
		)
		
		$("#select").click(function(){
			var sinsname=$("#sinsname").val();
			var spolicy=$("#spolicy").val();
			var regfrom=$(".datefrom").val();
			var regto=$(".dateto").val();
			var status=$("#sstatus").val();
			var spolicy=policyRefTo12($("#spolicy").val());
			$("#spolicy").val(spolicy);
			
			/*if(sinsname==""&&spolicy==""){
				if(status==""){
					if(regfrom==""&&regto==""){
						alertMsg("请选择查询条件");
						return;
					}
					if(regfrom!=""&&regto==""||regfrom==""&&regto!=""){
						alertMsg("受理日期输入不完整");
						return;
					}
					else{
						alertMsg("请输入保单状态");
						return;
					}
				}
				else{
					if(regfrom==""&&regto==""){
						alertMsg("请输入受理日期");
						return;
					}*/
					if(regfrom!=""&&regto==""||regfrom==""&&regto!=""){
						alertMsg("受理日期输入不完整");
						return;
					}
					if(regfrom!=""||regto!=""){
						var dates = new Date(regfrom).getTime()-new Date(regto).getTime();
						var days = Math.floor(dates/(24*3600*1000));
						if(days>90){
							alertMsg("时间差不能超过90天")
							return;
						}
					}
				//}
			//}
			
			//var jsonParam={"insuredName":sinsname,"policyRef":spolicy,"regDateFrom":regfrom,"regDateTo":regto,"claimStatus":status};
			//padMarketing.ajaxNormal(
				//'/pad_marketing/myPolicy/queryClaims.action',
				//jsonParam,
				//function(data){
					//console.log(data);
					window.location="/pad_marketing/MyPolicy/preserlist.action?insuredName="+sinsname+"&policyRef="+spolicy+"&regDateFrom="+regfrom+"&regDateTo="+regto+"&claimStatus="+status;
				//},
				//function(data){
					
				//}
			//)
		})
		
	}
	
	//理赔列表    '/pad_marketing/myPolicy/getClaims.action',
	if($("#biaoshi").val()=="8"){
		//理赔汇总
		/*padMarketing.ajaxNormal(
			    '/pad_marketing/myPolicy/findClaimNums.action',
			    {},
			    function(data){
			    	$(".lp").append('<label class="tag tag_1">'+data.claimNum+'</label>');	//承保前
			     	  
			    },
			    function(){
			    	
			    }
		)*/
		//var j= GetQueryString("policyRef");
		var jsonParam=parseQueryString(decodeURI(window.location.href));
		var paramObj = {insuredName:'',policyRef:'',regDateFrom:'',regDateTo:'',claimStatus:''};
		$.extend(paramObj,jsonParam);
		
		padMarketing.ajaxNormal(
				'/pad_marketing/myPolicy/queryClaims.action',
				paramObj,
				function(data){
					//console.log(data);
					var html='';
					if(data == '' || data == "undefined"){
						html='<tr><td colspan="7">暂无符合数据</td></tr>';
						$("#length").text("0");
						$(".presertable tbody").append(html);
					}
					else{
						for(var i=0;i<data.length;i++){
							var date=new Date(data[i].REG_DATE).Format("yyyy-MM-dd");;
							html+='<tr data=\''+JSON.stringify(data[i])+'\'>';
							html+='<td width="160">'+data[i].POLICY_REF+'</td>';//保单号
							html+='<td width="140">'+data[i].INSURED_NAME+'</td>';//被保险人
							html+='<td width="120">'+data[i].COVER_CODE+'</td>';//险种代码
							html+='<td width="120">'+data[i].SUM_ASSURED+'</td>';//保额
							html+='<td width="150">'+(data[i].REG_DATE?date:"")+'</td>'//受理日期							
							//理赔状态
							html+='<td>'+data[i].CLAIM_STATUS_NAME+'</td>';//
							/*if(data[i].CLAIM_STATUS=="P"||data[i].CLAIM_STATUS=="S"||data[i].CLAIM_STATUS=="T"){
								if(data[i].DECISION=="AP"||data[i].DECISION=="TB"||data[i].DECISION=="EX"||data[i].DECISION=="QC"||data[i].DECISION=="RJ"||data[i].DECISION=="DD"||data[i].DECISION=="WD"){
									html+='<td>审核中</td>';
								}
							}
							if(data[i].CLAIM_STATUS=="C"||data[i].CLAIM_STATUS=="D"){
								if(data[i].DECISION=="AP"||data[i].DECISION=="TB"||data[i].DECISION=="EX"||data[i].DECISION=="QC"||data[i].DECISION=="RJ"){
									html+='<td>已结案</td>';
								}
								if(data[i].DECISION=="DD"||data[i].DECISION=="WD"){
									html+='<td>案件撤销</td>';
								}
							}
							if(!data[i].CLAIM_STATUS||data[i].CLAIM_STATUS==""|| data[i].CLAIM_STATUS=="P"||data[i].CLAIM_STATUS=="S"||data[i].CLAIM_STATUS=="T"||data[i].CLAIM_STATUS=="C"||data[i].CLAIM_STATUS=="D"){
								if(!data[i].DECISION){
									html+='<td>受理中</td>';
								}
							}
							if(data[i].CLAIM_STATUS=="R"){
								html+='<td>受理中</td>';
							}*/
							html+='<td width="120">';
							//判断是否有理赔照会							
							if(data[i].NOTICE_ID){
								html+='<span class="icon icon-circle-pei pei"></span>';
							}//<span class="icon icon-circle-xiang check"></span>
							else{
								html+='';
							}
							html+='<span class="icon icon-circle-xiang check"></span></td>';
							html+='</td>';
							html+='</tr>';
						}
						$("#length").text(data.length);
						$(".presertable tbody").append(html);
					}
					
					//table();
					un();
					
					$(".presertable .pei").click(function(){
						
							var undermesg=JSON.parse($(this).closest('tr').attr("data"));
							var noticeId = undermesg.NOTICE_ID;
							var contract = undermesg.CONTRACT_ID;
							var address='';
							var sign="";
							//sign获取
							var signKey = noticeId+"NEWTOUCH";
							$.ajax({
								  url: '/pad_marketing/main/getSign.action',
								  data: {'jsonParam':JSON.stringify({signKey:signKey})},
								  success: function(data){
									  sign = data.sign;
									  address = data.address;
								  },
								  async:false
							}); 
							thisUrl = window.document.location.pathname;//当前URL
							//理赔照会URL
							var pdfUrl = address+"/CN0001?noticeId="+noticeId+"&partner=NEWTOUCH&sign="+sign;
							//console.log(pdfUrl)
							//调壳弹出新页面，参数说明：1：回调函数名称，2：要展示的地址，3：回调函数参数，4：是否需要签字
							gotoPDF('pdfRefresh',pdfUrl,0,'N');
							
						
					})
					
					$(".presertable .check").click(function(){
						$(".open-body div div p").text("");
						var undermesg=JSON.parse($(this).closest('tr').attr("data"));
						console.log(undermesg);
						/*padMarketing.ajaxNormal(
								'/pad_marketing/myPolicy/getPolicyClaim.action',
								{contractId:undermesg.CONTRACT_ID},
								function(result){
									console.log(result);
									for(var i=0;i<result.length;i++){
										if(result[i].SUM_INSURED==undermesg.SUM_ASSURED){
											//console.log(result[i])
*/											$("#claimid").text(undermesg.CLAIM_ID);//理赔号
											$("#covercode").text(undermesg.COVER_CODE);//险种代码
											$("#insuredname").text(undermesg.INSURED_NAME);//被保险人
											$("#sumassured").text(undermesg.SUM_ASSURED);//保额
											$("#causeloss").text(undermesg.COL_NAME);//出险原因
											$("#status").text(undermesg.CLAIM_STATUS_NAME);//理赔状态
											$("#decisiondesc").text(undermesg.DECISION);//理赔决定
											if(undermesg.NOTICE_ID){
												$("#notciestatus").text("未回复");//照会状态
											}
											else{
												$("#notciestatus").text("已回复");//照会状态
											}
											$("#loss").text(undermesg.DATE_OF_LOSS?new Date(undermesg.DATE_OF_LOSS).Format("yyyy-MM-dd"):'');//事故日
											$("#operating").text(undermesg.REG_DATE?new Date(undermesg.REG_DATE).Format("yyyy-MM-dd"):"");//受理确认日期
											$("#confirm").text(undermesg.CONFIRM_DATE?new Date(undermesg.CONFIRM_DATE).Format("yyyy-MM-dd"):"");//结案日期
											showDiv("open1");
										/*}
									}
									showDiv("open1");
								},
								function(data){
									
								},
								true,
								true,
								'呦!你的保单很多哦!'
						)*/
						/*sessionStorage.data=JSON.stringify(undermesg);
						window.location="/pad_marketing/MyPolicy/query.action?page=lp";*/
					})
					
					if(myScroll)
						myScroll.refresh();
				},
				function(data){
					
				},
				true,
				true,
				'呦!你的保单很多哦!'
			);
	}
	
	//续期待收
	if($("#biaoshi").val()=="9"){
		//续期待收汇总
		/*padMarketing.ajaxNormal(
			    '/pad_marketing/myPolicy/findOcpNums.action',
			    {},
			    function(data){
			    	$(".xqds").append('<label class="tag tag_1">'+data.ocpPolicyNum+'</label>');	//承保前
			    },
			    function(){
			    	
			    }
		)*/
		var jsonParam=parseQueryString(decodeURI(window.location.href));
		var paramObj = {};
		$.extend(paramObj,jsonParam);
		
		padMarketing.ajaxNormal(
				'/pad_marketing/ocp/getOcpDetailList.action',
				paramObj,
				function(data){	
					//console.log(data);
					var html='';
					var sum=0;
					if(data == '' || data == undefined){
						html='<tr><td colspan="7">暂无符合数据</td></tr>';
						$("#length").text("0");
						$(".renewsum").text("0");
						$(".renewaltable tbody").append(html);
					}
					else{											
						for(var i=0;i<data.length;i++){
							var fromdate=new Date(data[i].FROM_DATE).Format("yyyy-MM-dd");;
							//console.log()
							html+='<tr data=\''+JSON.stringify(data[i])+'\'>';
							html+='<td width="160">'+data[i].POLICY_REF+'</td>';//保单号
							html+='<td width="130">'+data[i].PH_NAME+'</td>';//投保人
							html+='<td width="120">'+data[i].COVER_CODE+'</td>';//主险代码
							html+='<td width="130">'+data[i].RENEW_PREMIUM+'</td>';//应收保费
							html+='<td>'+(data[i].FROM_DATE?fromdate:"")+'</td>';//续保到日期
							//html+="<td>"+data[i].FROM_DATE+"</td>";
							html+='<td width="150">'+data[i].DDA_BANK_NAME+'</td>';//转账银行
							html+='<td width="100"><span class="icon icon-circle-xiang check"></span></td>';
							html+='</tr>';
							sum +=data[i].RENEW_PREMIUM;
						}
						$("#length").text(data.length);
						$(".renewaltable tbody").append(html);
						$(".renewsum").text(sum.toFixed(2))
					}
					un();
					//table();
					$(".renewaltable .check").click(function(){	
						$(".open-body div div p").text("");
						var undermesg=JSON.parse($(this).closest('tr').attr("data"));
						var fromdate=new Date(undermesg.FROM_DATE).Format("yyyy-MM-dd");
						$("#policyRef").text(undermesg.POLICY_REF);//保单号
						$("#phname").text(undermesg.PH_NAME);//投保人
						$("#covercode").text(undermesg.COVER_CODE);//主险代码
						$("#premium").text(undermesg.RENEW_PREMIUM);//应收保费
						$("#fromdate").text(undermesg.FROM_DATE?fromdate:"");//续保到日期
						$("#bankname").text(undermesg.DDA_BANK_NAME?undermesg.DDA_BANK_NAME:"");//转账银行
						var date=new Date(undermesg.FROM_DATE).Format("yyyy-MM-dd");
						var id=undermesg.CONTRACT_ID;
						var par={"fromDate" : date,"contractId":id.toString()};
						//续期代收详情
						padMarketing.ajaxNormal(
							'/pad_marketing/ocp/getOcpListDetail.action',
							par,
							function(data){
								//console.log(data)
								var last=new Date(data.LAST_DDA_DATE).Format("yyyy-MM-dd");
								//console.log(last)
								$("#cover").text(data.COVER_ABBR_NAME)//主险名称
								$("#year").text(data.POLICY_YEAR)//保单年度
								$("#pay").text(data.PAYMENT_METHOD);//支付方式
								$("#banklast").text(data.DDA_ACCOUNT_NO);//银行卡后四位
								$("#perdate").text(data.LAST_DDA_DATE?last:'');//上次扣款日期
								$("#fail").text(data.DDA_FAIL_REASON);//扣款失败原因
							},
							function(data){
								
							},
							true,
							true,
							'详情很多，请耐心等待'
						)																	
						showDiv("open1");
					})
					if(myScroll)
						myScroll.refresh();
				},
				function(data){
					
				},
				true,
				true,
				'呦!你的保单很多哦!'
			);
	}
	
	//保单查询
	if($("#biaoshi").val()=="10"){
		//policy("policyhNo");
		/*$(".datefrom").val(newdate.Format("yyyy-MM-dd"));
		$(".dateto").val(today.Format("yyyy-MM-dd"));
		$(".accfrom").val(newdate.Format("yyyy-MM-dd"));
		$(".accto").val(today.Format("yyyy-MM-dd"));*/
		//保单状态下拉框
		padMarketing.ajaxNormal(
				'/pad_marketing/myPolicy/getPolicyStatus.action',
				{},
				function(data){
					//console.log(data);
					var html="";
					$("#stateT").change(function(){
						//var html="";
						if($("#stateT").val()=="承保前"){
							var html="";
							$("#state option").eq(0).siblings().remove();
							for(var i=0;i<data.length;i++){
								if(data[i].CODE < 39){
									html += "<option value="+data[i].CODE+">"+data[i].DESCRIPTION_C+"</option>";
								}
							}
							$("#state").append(html);
							return;
						}
						if($("#stateT").val()=="承保后"){
							var html="";
							$("#state option").eq(0).siblings().remove();
							for(var i=0;i<data.length;i++){
								if(data[i].CODE > 38){
									html += "<option value="+data[i].CODE+">"+data[i].DESCRIPTION_C+"</option>";
								}
							}
							$("#state").append(html);
							return;
						}
						else{
							$("#state option").eq(0).siblings().remove();
						}
					})
						//html += "<option value="+data[i].CODE+">"+data[i].DESCRIPTION_C+"</option>";
					//$("#state").append(html);
				},
				function(data){
					
				}
		);
		
		$("#stateT").change(function(){
			if($("#stateT").val()=="承保前"){
				$("#af input[data-role='datebox']").mobiscroll('disable');
				$("#af input").css("background","#eee")
				$("#at input[data-role='datebox']").mobiscroll('disable');
				$("#at input").css("background","#eee")
			}
			if($("#stateT").val()=="承保后"){
				$("#af input[data-role='datebox']").mobiscroll('enable');
				$("#af input").css({"background":"url(/pad_marketing/html/img/icon-date-gray.png) 95% center no-repeat","background-size": "auto 50%"})
				$("#at input[data-role='datebox']").mobiscroll('enable');
				$("#at input").css({"background":"url(/pad_marketing/html/img/icon-date-gray.png) 95% center no-repeat","background-size": "auto 50%"})
			}
		})
		
		//查询
		$("#select").click(function(){
			
			var phName=$("#phName").val();//投保人
			//var insNames=$("#insNames").val();//被保险人
			//var policyRef=$("#policyRef").val();//保单号
			var policyhNo=$("#policyhNo").val();//投保单号
			var effstart=$(".datefrom").val();//受理日期开始
			var effend=$(".dateto").val();//受理日期结束
			var accstart=$(".accfrom").val();//生效日期开始
			var accend=$(".accto").val();//生效日期结束
			//var state=$("#state").find("option:selected").text();//保单状态
			var state=$("#state").val();//保单状态
			if(!state){//undefined\""\null\0
				var stateArr = [];
				var stateT = $('#stateT').val();
				if(stateT){
					$("#state option").each(function(){
						var val = $(this).val();
						if(val)
							stateArr.push(val);
					})
				}
				if(stateArr.length>0)
					state = stateArr.join(',');
			}
			
			var policyRef=policyRefTo12($("#policyRef").val());
			$("#policyRef").val(policyRef);
			
			if(policyRef==""&&policyhNo==""&&phName==""){
				if(state==""){
					if(effstart==""&&effend==""){
						if(accstart==""&&accend==""){
							alertMsg("请填写查询条件");
							return;
						}
						if(accstart!=""&&accend=="" || accstart==""&&accend!=""){
							alertMsg("生效日期输入不完整");
							return;
						}
						else{
							var dates = new Date(accstart).getTime()-new Date(accend).getTime();
							var days = Math.floor(dates/(24*3600*1000));
							if(days>90){
								alertMsg("生效日期时间差不能超过90天")
								return;
							}
						}
					}
					if(effstart!=""&&effend==""||effstart==""&&effend!=""){
						alertMsg("受理日期输入不完整");
						return
					}
					else{
						var date = new Date(effstart).getTime()-new Date(effend).getTime();
						var day = Math.floor(dates/(24*3600*1000));
						if(day>90){
							alertMsg("受理日期时间差不能超过90天")
							return;
						}
					}
				}
				if(state!=""){
					if(parseInt($("#state").val())<39){
						if(effstart==""&&effend==""){
							alertMsg("请选择受理日期");
							return;
						}
						if(effstart!=""&&effend==""||effstart==""&&effend!=""){
							alertMsg("受理日期输入不完整");
							return;
						}
						else{
							var dates = new Date(effstart).getTime()-new Date(effend).getTime();
							var days = Math.floor(dates/(24*3600*1000));
							if(days>90){
								alertMsg("受理日期时间差不能超过90天")
								return;
							}
						}
					}
					else{
						if(effstart==""&&effend==""){
							if(accstart==""&&accend==""){
								alertMsg("请任意选择一个日期");
								return;
							}
							if(accstart!=""&&accend=="" || accstart==""&&accend!=""){
								alertMsg("生效日期输入不完整");
								return;
							}
							else{
								var dates = new Date(accstart).getTime()-new Date(accend).getTime();
								var days = Math.floor(dates/(24*3600*1000));
								if(days>90){
									alertMsg("生效日期时间差不能超过90天")
									return;
								}
							}
						}
						if(effstart!=""&&effend==""||effstart==""&&effend!=""){
							alertMsg("受理日期输入不完整");
							return;
						}
						else{
							var date = new Date(effstart).getTime()-new Date(effend).getTime();
							var day = Math.floor(dates/(24*3600*1000));
							if(day>90){
								alertMsg("受理日期时间差不能超过90天")
								return;
							}
						}
					}
				}
				if(phName=="" && state==""){
					if(effstart=="" && effend=="" || accstart=="" && accend==""){
						alertMsg("请输入查询条件");
						return;
					}
					else{
						var dates = new Date(effstart).getTime()-new Date(effend).getTime();
						var days = Math.floor(dates/(24*3600*1000));
						if(days>90){
							alertMsg("受理日期时间差不能超过90天")
							return;
						}
						var dates2 = new Date(accstart).getTime()-new Date(accend).getTime();
						var days2 = Math.floor(dates2/(24*3600*1000));
						if(days2>90){
							alertMsg("生效日期时间差不能超过90天")
							return;
						}
					} 
				}
			}
			else{
				if(effstart!='' && effend!=''){
					var dates = new Date(effstart).getTime()-new Date(effend).getTime();
					var days = Math.floor(dates/(24*3600*1000));
					if(days>90){
						alertMsg("受理日期时间差不能超过90天")
						return;
					}
				}
				if(effstart=='' && effend!=''||effstart!='' && effend==''){
					alertMsg("受理日期输入不完整");
					return;
				}
				if(accstart !='' && accend !=''){
					var dates2 = new Date(accstart).getTime()-new Date(accend).getTime();
					var days2 = Math.floor(dates2/(24*3600*1000));
					if(days2>90){
						alertMsg("生效日期时间差不能超过90天")
						return;
					}
				}
				if(accstart =='' && accend !=''||accstart !='' && accend ==''){
					alertMsg("生效日期输入不完整");
					return;
				}
				
			}
			
			window.location.href="/pad_marketing/MyPolicy/querylist.action?phName="+phName+"&policyRef="+policyRef+"&prePrintedNo="+policyhNo+"&entryFrom="+effstart+"&entryTo="+effend+"&inceptionFrom="+accstart+"&inceptionTo="+accend+"&policyStatus="+state;
			//var par={"phName":phName,"policyRef":policyRef,"prePrintedNo":policyhNo,"entryFrom":effstart,"entryTo":effend,"inceptionFrom":accstart,"inceptionTo":accend,"policyStatus":state};
		})
	}
	
	if($("#biaoshi").val()=="11"){
		
		$("#close").click(function(){
			closeDiv('open1');
			setTimeout(function(){
				$("#myTab1 li").eq(0).addClass('active');
				$("#myTab1 li").eq(0).siblings().removeClass('active');
				$("#myTab1_Content0").show();
				$("#myTab1_Content0").siblings().hide();
			},200)
			
		})
		
		var jsonParam=parseQueryString(decodeURI(window.location.href));
		var paramObj = {phName:'',policyRef:'',prePrintedNo:'',entryFrom:'',entryTo:'',inceptionFrom:'',inceptionTo:'',policyStatus:''};
		$.extend(paramObj,jsonParam);
		//查询
		padMarketing.ajaxNormal(
				'/pad_marketing/myPolicy/queryPolicies.action',
				paramObj,
				function(data){
					var tab='';
					//console.log(data);
					if(!data){
						tab+='<tr><td colspan="8">暂无符合数据</td></tr>';
						$("#length").text("0");
						$(".querytable tbody").append(tab);
					}
					else{
						$('#length').text(data.length||0);
						for(var i=0;i<data.length;i++){
							var fromdate=new Date(data[i].FROM_DATE);									
							tab+='<tr data-policy=\''+JSON.stringify(data[i])+'\'>';
							if(data[i].POLICY_SOURCE=="孤儿保单"){
								tab+='<td width="190"><span class="red">[孤]</span>'+data[i].POLICY_REF+'</td>';//保单号
							}
							else{
								tab+='<td width="190">'+data[i].POLICY_REF+'</td>';//保单号
							}					
							tab+='<td width="130">'+data[i].POLICY_STATUS+'</td>';//保单状态
							tab+='<td width="120">'+data[i].PH_NAME+'</td>';//投保人
							tab+='<td width="120">'+data[i].INS_NAMES+'</td>';//被保人
							tab+='<td width="160">'+data[i].COVER_CODE+'</td>';//主险代码
							tab+='<td width="120">'+data[i].REGULAR_PREM+'</td>';//期交保费
							tab+='<td>'+data[i].SOURCE_NAME+'</td>';//出单方式
							tab+='<td width="100"><span class="icon icon-circle-xiang check"></span></td>';
							tab+='</tr>';
						}
						$("#length").text(data.length);
						$(".querytable tbody").append(tab);
					}
					//$(".querytable tbody tr").remove();
					un();
					//table();
					$('.querytable .check').click(function(){
						$(".open-body div div p").text("");
						showPolicyDetails(this);
					});
					if(myScroll)
						myScroll.refresh();
					},
				function(data){
					//console.log(data)
				},
				true,
				true,
				'呦!你的保单很多哦!'
		);
		
		function showPolicyDetails(span){
			$("#showEInvoiceList").hide();
			showLoadingPad();
			var policyData = $(span).closest('tr').data('policy');
			sessionStorage.policyData = JSON.stringify(policyData);
			sessionStorage.contractId = policyData.CONTRACT_ID;
			var contractId = policyData.CONTRACT_ID
			//var undermesg=JSON.parse($(this).closest('tr').attr("data"));
			//jsonParam.contractId=undermesg.CONTRACT_ID;
			
			/*window.frames['xzlist'].xzxx();
			window.frames['stflist'].stf();
			window.frames['tllist'].tlxx();
			window.frames['bqlist'].bq();
			window.frames['lplist'].lp();*/
			
			//基本信息
			$("#jb p").html();
			$("#jz p").html();
			padMarketing.ajaxNormal(
				'/pad_marketing/myPolicy/getWarranty.action',
				{contractId:contractId},
				function(data){
					//console.log(data);
					if($.type(data)=='array'&&data.length==1)
						data = data[0];
					$("#policyref").text(data.POLICY_REF);//保单号
					$("#preno").text(data.PRE_PRINTED_NO);//投保单号
					$("#issuedate").text(data.ISSUE_DATE?new Date(data.ISSUE_DATE).Format("yyyy-MM-dd"):"");//保单承保日
					$("#incdate").text(data.INCEPTION_DATE?new Date(data.INCEPTION_DATE).Format("yyyy-MM-dd"):'');//保单生效日
					$("#paytype").text(data.PAYMENT_MODE);//缴费方式
					$("#payment").text(data.PAYMENT_METHOD);//交费方式
					$("#polterm").text(data.POLICY_TERM);//保险年限
					$("#preterm").text(data.PREMIUM_TERM);//保费年限
					$("#bankname").text(data.DDA_BANK_NAME);//开户行
					$("#bankno").text(data.DDA_BANK_ACCOUNT_NO);//银行转账账户
					$("#payer").text(data.PAYER);//账户所有人
					$("#coverid").text(policyData.COVER_CODE);//主险代码
					$("#covername").text(data.COVER_ABBR_NAME);//主险简称
					$("#sum").text(data.MAIN_COVER_SA);//主险保额
					$("#polname").text(policyData.PH_NAME);//投保人
					$("#issname").text(policyData.INS_NAMES);//被保险人
					$("#polstatus").text(policyData.POLICY_STATUS);//保单状态
					$("#regular").text(policyData.REGULAR_PREM);//期交保费
					$("#source").text(data.POLICY_SOURCE);//保单来源
					hideLoadingPad();
				},
				function(){
											
				},
				true,
				true,
				'呦!你的保单很多哦!'
			)
			
			//保单价值
			padMarketing.ajaxNormal(
				'/pad_marketing/myPolicy/getPolicyValue.action',
				//jsonParam,
				{contractId:contractId},
				function(data){
					//console.log(data);	
					if($.type(data)=='array'&&data.length==1)
						data = data[0];
					$('#amount').text(data.LOAN_AMOUNT);//已贷款金额
					$('#cashvalue').text(data.CASH_VALUE);//现金价值
					$('#isrpu').text(data.IS_RPU);//是否减额缴清
					//$('#rpudate').text(data.RPU_DATE?data.RPU_DATE:'');//减额缴清生效日 
					if(data.RPU_DATE){
						if(data.RPU_DATE=='-'){
							$('#rpudate').text(data.RPU_DATE);//减额缴清生效日 
						}
						else{
							$('#rpudate').text(new Date(data.RPU_DATE).Format("yyyy-MM-dd"));
						}
					}
					else{
						$('#rpudate').text("");//减额缴清生效日 
					}
				},
				function(){
											
				},
				true,
				true,
				'呦!你的保单很多哦!'
			)
			
			//投连账户是否显示
			padMarketing.ajaxNormal(
				'/pad_marketing/myPolicy/isDisplay.action.action',
				{contractId:contractId},
				function(data){
					//console.log(data);
					if($.type(data)=='array'&&data.length==1&&data[0])
						data = data[0];
					if(data.DISPLAY == 'TRADITIONAL'){//TRADITIONAL	UNIT LINK
						$("#tl").show();
						
					}
					else{
						$("#tl").hide();
					}
					
				},
				function(){
												
				},
				true,
				true,
				'呦!你的保单很多哦!'
			)
			
			
			//客户信息
			$("#myTab1_title1").off('click').click(function(){
				$("#showEInvoiceList").hide();
				$("#kh p").html();
				padMarketing.ajaxNormal(
						'/pad_marketing/myPolicy/getClientInfo.action',
						{contractId:contractId},
						function(data){
							//console.log(data);	
							var originHtml = $('#myTab1_Content1 .panel:eq(0)')[0].outerHTML;
							//console.log(originHtml)
							$('#myTab1_Content1 .panel').remove();
							var html2='<label class="col-md-3 control-label">受益类型</label><div class="col-md-3"><p class="form-control-static blue" id="sytype"></p></div><div class="clearfix"></div><label class="col-md-2 control-label">受益顺序</label><div class="col-md-4"><p class="form-control-static blue" id="sysx"></p></div><label class="col-md-3 control-label">受益比例(%)</label><div class="col-md-3"><p class="form-control-static blue" id="sybl"></p></div><div class="clearfix"></div>';
							for(var i=0;i<data.length;i++){
								
								$('#myTab1_Content1').append(originHtml);
								if(data[i].ROLE_TYPE=="受益人"){
									$('#myTab1_Content1 .panel-primary').eq(i).find("#posb").before(html2);
								}
								
								var pArr = $('#myTab1_Content1 .panel:last p');
								//console.log(pArr)
								pArr.eq(0).text(data[i].ROLE_TYPE);//人员类型
								pArr.eq(1).text(data[i].NAME);//姓名
								pArr.eq(2).text(data[i].SEX);//性别
								pArr.eq(3).text(data[i].DATE_OF_BIRTH);//出生日期
								pArr.eq(4).text(data[i].ID_NO);//证件号码
								pArr.eq(5).text(data[i].MOBILE_PHONE);//手机号码
								pArr.eq(6).text(data[i].TELEPHONE);//固定电话
								pArr.eq(7).text(data[i].POST_CODE);//邮编
								pArr.eq(8).text(data[i].ADDRESS);//联系地址
								pArr.eq(9).text(data[i].BENEFICIARY_TYPE);//收益类型
								pArr.eq(10).text(data[i].BEN_SEQ);//收益顺序
								pArr.eq(11).text(data[i].BEN_SHARE);//收益比例
							}
						},
						function(){
							
						},
						true,
						true,
						'呦!你的保单很多哦!'
					)
			})
			//险种信息
			$("#myTab1_title2").off('click').click(function(){
				//window.frames['xzlist'].xzxx();
				$("#showEInvoiceList").hide();
				$('#xzlist').attr('src','/pad_marketing/html/query-xz.html?contractId='+contractId);
			})
			//收退费
			$("#myTab1_title3").off('click').click(function(){
				$("#showEInvoiceList").show();
				//window.frames['stflist'].stf();
				$('#stflist').attr('src','/pad_marketing/html/query-stf.html?contractId='+contractId);
			})
			//万能账户是否显示
			padMarketing.ajaxNormal(
				'/pad_marketing/myPolicy/isShowSuper.action',
				{contractId:contractId},
				function(data){
					console.log(data);
					if($.type(data)=='array'&&data.length==1&&data[0])
						data = data[0];
					if(data.DISPLAY == 'PARTICIPATING'){//TRADITIONAL  PARTICIPATING   //UNIVERSAL
						$("#wn").show();
					}
					else{
						$("#wn").hide();
					}
					
				},
				function(){
												
				},
				true,
				true,
				'呦!你的保单很多哦!'
			)
			
			//万能账户信息   /pad_marketing/myPolicy/getSuperUser.action
			$("#wn").off('click').click(function(){
				$("#showEInvoiceList").hide();
				padMarketing.ajaxNormal(
						'/pad_marketing/myPolicy/getSuperUser.action',
						{contractId:contractId},
						function(data){
							console.log(data);
							var html="";
							for(var i=0;i<data.length;i++){
								html+="<tr>";
								html+="<td>"+data[i].INV_ACC_NAME_CN+"</td>";//投资账户
								html+="<td>"+data[i].PRINCIPLE_AMT+"</td>";//本金(元)
								html+="<td>"+data[i].ACCRUED_INTEREST+"</td>";//利息(元)
								html+="<td>"+data[i].ACCOUNT_VALUE+"</td>";//账户价值(元)
								html+="</tr>";
							}
							$("#wnxx tbody").append(html);
							un();
						},
						function(data){
							
						},
						true,
						true,
						'呦!你的保单很多哦!'
				)
			})
			//投连账户信息
			$("#tl").off('click').click(function(){
				$("#showEInvoiceList").hide();
				//window.frames['tllist'].tlxx();
				$('#tllist').attr('src','/pad_marketing/html/query-tlxx.html?contractId='+contractId);
			})
			//保全任务记录
			$("#bqpage").off('click').click(function(){
				$("#showEInvoiceList").hide();
				//window.frames['bqlist'].bq();
				$('#bqlist').attr('src','/pad_marketing/html/query-bq.html?contractId='+contractId);
			})
			//保单理赔记录
			$("#lppage").off('click').click(function(){
				$("#showEInvoiceList").hide();
				//window.frames['lplist'].lp();
				$('#lplist').attr('src','/pad_marketing/html/query-lp.html?contractId='+contractId);
			})
			
			showDiv("open1")
		}
	}
	
})

//排序插件
$.extend($,{
    //命名空间
    sortTable:{
        sort:function(tableId,Idx){
            var table = document.getElementById(tableId);
            var tbody = table.tBodies[0];
            var tr = tbody.rows;
    
            var trValue = new Array();
            
            for (var i=0; i<tr.length; i++ ) {
                trValue[i] = tr[i];  //将表格中各行的信息存储在新建的数组中
            }
            
            if (tbody.sortCol == Idx) {
                trValue.reverse(); //如果该列已经进行排序过了，则直接对其反序排列
            	iconUp(Idx);
            } else {
                //trValue.sort(compareTrs(Idx));  //进行排序
            	
                trValue.sort(function(tr1, tr2){ 
                    var value1 = tr1.cells[Idx].innerHTML;
                    var value2 = tr2.cells[Idx].innerHTML;
                    if(Number(value1)&&Number(value2)){
                    	return value1-value2;
                    }
                    return value1.localeCompare(value2);
                });
                
            	iconUp(Idx);
               
            }
    
            var fragment = document.createDocumentFragment();  //新建一个代码片段，用于保存排序后的结果
            for (var i=0; i<trValue.length; i++ ) {
                fragment.appendChild(trValue[i]);
            }
    
            tbody.appendChild(fragment); //将排序的结果替换掉之前的值
            tbody.sortCol = Idx;

            function iconUp(Idx){
            	var text =$(".primary th").eq(Idx).find(".icon_1").text();
            	if(text=="↓"){
            		$(".primary th").eq(Idx).find(".icon_1").text("↑");
            	}
            	else{
            		$(".primary th").eq(Idx).find(".icon_1").text("↓");
            	}
            }
        }
    }
})

//将url的参数转为对象
var parseQueryString = function (url) {
    var reg_url = /^[^\?]+\?([\w\W]+)$/,
            reg_para = /([^&=]+)=([\w\W]*?)(&|$)/g, //g is very important
            arr_url = reg_url.exec(url),
            ret = {};
    if (arr_url && arr_url[1]) {
        var str_para = arr_url[1], result;
        while ((result = reg_para.exec(str_para)) != null) {
            ret[result[1]] = result[2];
        }
    }
    return ret;
};

//获取总数量
function loadingNewData(update){
	if(update=='Y'){
		
	}else{
		if(sessionStorage.underwriteNum)
			return;
	}
	
	padMarketing.ajaxNormal(
    '/pad_marketing/myPolicy/getNumbers.action',
    {},
    function(data) {
    	//console.log(data);
    	sessionStorage.underwriteNum=data.underwriteNum;
    	sessionStorage.newOrdersNum=data.newOrdersNum;
    	sessionStorage.acceptNum=data.acceptNum;
    	sessionStorage.claimNum=data.claimNum;
    	sessionStorage.ocpPolicyNum=data.ocpPolicyNum;
    	sum();
    	  /* if(data.policiesNum > 0){
        	   $(".bdcx").append('<label class="tag tag_5">'+data.policiesNum+'</label>');		//保单查询
           }*/
       
    },
    function(data){},
    true,false)
    
}

function sum(){
	if(sessionStorage.underwriteNum > 0){
		$(".cbq").append('<label class="tag tag_1">'+sessionStorage.underwriteNum+'</label>');	//承保前
	}
	if(sessionStorage.newOrdersNum > 0){
		$(".xdzz").append('<label class="tag tag_2">'+sessionStorage.newOrdersNum+'</label>');		//新单追踪
	}
	if(sessionStorage.acceptNum > 0){
		$(".bq").append('<label class="tag tag_3">'+sessionStorage.acceptNum+'</label>');	//保全
	}
	if(sessionStorage.claimNum > 0){
		$(".lp").append('<label class="tag tag_4">'+sessionStorage.claimNum+'</label>');		//理赔
	}
	if(sessionStorage.ocpPolicyNum > 0){
		$(".xqds").append('<label class="tag tag_5">'+sessionStorage.ocpPolicyNum+'</label>');		//续期代收
	}
}

//保单号补全
function policy(id){
	$("#"+id).blur(function() {
	    var v=this.value;	    
	    if(v.length == 12 || v.length <=0){
	    	return;
	    }else{
	        while(v.length<12){v='0'+v;}this.value=v;
	    }
	});
	
}


//判断页面上的undefined
function un(){
	for(var j=0;j<$(".table tbody td").length;j++){
		if($(".table tbody td").eq(j).text()=="undefined"){
			$(".table tbody td").eq(j).text("");
		}
	}
}

//时间初始化
var today=new Date();
var sjc=Math.floor(30*(24*3600*1000));
//var newdate = new Date(today.getTime()-sjc).Format("yyyy-MM-dd");
var newdate=new Date();
newdate.setMonth(newdate.getMonth()-1);
newdate.setDate(newdate.getDate());

//重置
function rest(){
	$("#con").find("input").val("");
	$("#con").find("select").val("请选择");
	/*$(".changef").val(newdate.Format("yyyy-MM-dd"));
	$(".changet").val(today.Format("yyyy-MM-dd"));*/
	/*$(".datefrom").val(newdate.Format("yyyy-MM-dd"));
	$(".dateto").val(today.Format("yyyy-MM-dd"));
	$(".accfrom").val(newdate.Format("yyyy-MM-dd"));
	$(".accto").val(today.Format("yyyy-MM-dd"));*/
	$("table tbody tr").remove();
}

function GetQueryString(name){
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if(r!=null)return  unescape(r[2]); return null;
}

//表头固定
//function table(){
//	$("#tablesort").mobileFixedColumnsTable({
//		'sScrollY': '410px',
//	        'sScrollX': '100%',
//	        'bScrollCollapse': true,
//	        'oLanguage': {
//	            'sInfo': ''
//	        	}
//	    	}, {
//	        fixedColumnsOptions: {
//	            iLeftColumns: 0
//	     	}
//	})
//}


